<template>
  <div>
    <el-form v-show="isShow"  :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-card>
        <div class="content">
          <div class="title">
            <span>免费咨询</span>
            <i @click="close"  class="icon-close" ref="close"></i>          
          </div>
          <span class="title2">留下您的联系方式，不久后会收到来电</span>
          <div class="bottom">
            <el-form-item class="row row1" label="姓名" prop="name">
              <el-input class="input" placeholder="请填写您的姓名" type="text" v-model="ruleForm.name" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item class="row row2" label="手机" prop="mobile">
              <el-input class="input" placeholder="请输入您的手机号" type="text" v-model="ruleForm.mobile" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item class="row row3" label="验证" prop="verify">
              
              <el-input class="input" placeholder="请输入验证码" type="text" v-model="ruleForm.verify" autocomplete="off"></el-input>
              <el-button class="btn-get-sms">短信验证码</el-button>
            </el-form-item>
            <el-form-item class="row row4" label="驾照" prop="license">
              <el-input class="input" type="text" v-model="ruleForm.license" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item class="row row5" label="位置" prop="position">
              <el-input class="input" type="text" v-model="ruleForm.position" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item class="row row6">
              <el-button class="submit-btn" type="primary" @click="submitForm('ruleForm')">提交</el-button>
            </el-form-item>
          </div>
        </div>
        <div class="agree">
          <input type="checkbox">同意
          <a href="https://laofuzi.kakamobi.com/agreements/privateAgreement.html?_productCategory=jiakaobaodian&amp;_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8&amp;_appName=jiakaobaodian#/">《隐私政策》</a>和
          <a href="https://share-m.kakamobi.com/activity.kakamobi.com/jiakaobaodian-info-guard/">《个人信息保护声明》</a>
  
        </div>
      </el-card>
    </el-form>
  </div>
</template>
<script>
  export default {

    data() {
      
      var validateName = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入密码'));
        } 
      };
      var validateMobile = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入手机号'));
        } 
      };
      var validateVerify = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入验证码'));
        } 
      };
      var validateLicense = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('驾照不能为空'));
        } 
      };
      var validatePosition = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('位置不能为空'));
        } 
      };
     
      
      return {
        isShow: true,
        ruleForm: {
          name: '',
          mobile: '',
          verify: '',
          license: '',
          position: '',
        },
        rules: {
          name: [
            { validator: validateName, trigger: 'blur' }
          ],
          mobile: [
            { validator: validateMobile, trigger: 'blur' }
          ],
          verify: [
            { validator: validateVerify, trigger: 'blur' }
          ],
          license: [
            { validator: validateLicense, trigger: 'blur' }
          ],
          position: [
            { validator: validatePosition, trigger: 'blur' }
          ],
        }
      };
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('submit!');
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      },
      open (){
              this.isShow = true
            },
            close(){
              this.isShow = false
            }
      
    }
  }
</script>

<style lang="scss" scoped>
.demo-ruleForm{
      
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, .65);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  border: 1px solid #e9e9e9;
  border-radius: 8px;
  .content{
    text-align: center;
    font-size: 16px;
    background-color: #fff;
    //padding-bottom: 30px;
    .title{
      font-weight: 600;
      font-size: 20px;
      line-height: 28px;
      color: #333;
      letter-spacing: 3px;
      display: flex;
      justify-content: center;
      align-items: center;
      position: relative;
      padding: 7px 0;

      .icon-close{
        display: block;
        width: 17px;
        height: 17px;
        background: url(../assets/close.jpg) no-repeat;
        background-size: 100% 100%;
        cursor: pointer;
        position: absolute;
        right: 0;
        top: 0;
      }
    }
    .title2{
      font-size: 14px;
      font-weight: 400;
      color: #999;
      line-height: 20px;
    }
    
    .bottom{

      .row{
        margin: 20px 0;
        span{
          font-size: 16px;
          display: inline-block;
          width: 38px;
          text-align: right;
          vertical-align: middle;
          font-weight: 500;
          color: #333;
        }
        .input{
          height: 50px;
          width: 400px;
          margin-left: 20px;
          padding: 0 10px;
          font-size: 16px;
          
          overflow: hidden;
          border-radius: 4px;
          line-height: 50px;
          vertical-align: middle;
          color: #333;
          outline: 0;
          &:hover{
              //border: 1px solid pink;
          }
        }
      }
      .row3{
        //margin-left: 70px;
        .input{
          width: 270px;
        }
        .btn-get-sms{
          width: 120px;
          height: 40px;
          //line-height: 40px;
          background: #04a5ff;
          border: none;
          color: #fff;
          text-align: center;
          border-radius: 4px;
          margin-right: 10px;
          //margin-left: 10px;
          vertical-align: middle;
        }
        
      }
      .row4{
        select{
          height: 50px;
          width: 400px;
          margin-left: 20px;
          padding: 0 10px;
          font-size: 16px;
          border: 1px solid #e9e9e9;
          overflow: hidden;
          border-radius: 4px;
          line-height: 50px;
          vertical-align: middle;
          color: #333;
        }
        .type{
          padding-right: 20px;
          appearance: none;
          
          background: url(../assets/down.png) right 8px center no-repeat;
        }
      }
      .row6{
        margin-top: 30px;
        padding-right: 0;
        .submit-btn{
          display: block;
          width: 100%;
          height: 40px;
          //line-height: 50px;
          border: none;
          background: #04a5ff;
          border-radius: 4px;
          color: #fff;
          font-size: 18px;
        }
      }
    }
  }
  .agree{
    font-size: 14px;
    color: #333333;
    margin-top: 0px;
    text-align: center;
  }
}
</style>